-
Notifications
You must be signed in to change notification settings - Fork 19
OAI-PMH 2.0 Implementation to export Materials #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Oai pmh support
Oai pmh repo url fix
Merge remote changes and small OAI-PMH fixes
Merge main developments into oai-pmh branch
Remaining TODOs for this pull request:
|
config/environment.rb
Outdated
class PublicMaterial < Material | ||
default_scope { where(visible: true) } | ||
|
||
# Pretend to be a regular Material (for URLs in RDF serialization) | ||
def self.model_name | ||
Material.model_name | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs, we can pass a scoped relation to OAI::Provider::ActiveRecordWrapper.new
instead of needing to make a new class:
https://github.com/code4lib/ruby-oai/blob/master/lib/oai/provider.rb#L249-L253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Changed in 7c2a9e7.
app/models/material.rb
Outdated
# Dublin Core mappings for OAI-PMH | ||
# no mapping needed for contributor, description and title | ||
# coverage and source not mappable | ||
alias_attribute :creators, :authors | ||
|
||
def dates | ||
[date_published, date_created, date_modified].compact.map(&:iso8601) | ||
end | ||
|
||
def format = 'text/html' | ||
|
||
def identifier | ||
if !doi.nil? && !doi.empty? | ||
doi_iri = doi.start_with?('http://', 'https://') ? doi : "https://doi.org/#{doi}" | ||
else | ||
url | ||
end | ||
end | ||
|
||
def language = 'en' | ||
|
||
def publishers | ||
if content_provider | ||
[content_provider.title] | ||
else | ||
[] | ||
end | ||
end | ||
|
||
# currently only url of tess resource, content provider url | ||
def relations | ||
[ | ||
"#{TeSS::Config.base_url}#{Rails.application.routes.url_helpers.material_path(self)}" | ||
] + (content_provider ? [content_provider.url] : []) | ||
end | ||
|
||
alias_attribute :rights, :licence | ||
|
||
def subjects | ||
keywords + scientific_topics.map(&:uri) + operations.map(&:uri) | ||
end | ||
|
||
def types | ||
['http://purl.org/dc/dcmitype/Text', 'https://schema.org/LearningResource'] + resource_type | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if we could move these methods into another class if that's possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to one method in 8b54db2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 small review comment and a general question:
How could we extend this to also include events? Would it need a new OAI "provider"?
def to_rdf | ||
jsonld_str = to_bioschemas[0].to_json | ||
|
||
graph = RDF::Graph.new | ||
JSON::LD::Reader.new(jsonld_str) do |reader| | ||
reader.each_statement { |stmt| graph << stmt } | ||
end | ||
|
||
rdfxml_str = graph.dump(:rdfxml, prefixes: { sdo: 'http://schema.org/', dc: 'http://purl.org/dc/terms/' }) | ||
rdfxml_str.sub(/\A<\?xml.*?\?>\s*/, '') # remove XML declaration because this is used inside OAI-PMH response | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
Summary of changes
/oai-pmh
that allows harvesting of visible training materials in Dublin Core and RDF (Bioschemas) metadata standardMotivation and context
This is a relevant step in the mTeSS-X project.
Screenshots
Checklist
to license it to the TeSS codebase under the
BSD license.